# -*- encoding: utf-8 -*-
"""
@author: CarpeDiem
@data: 22/9/17
@version: 0.1
@description: 穷举法算出回文数
@method: 要求是合法日期的八位数，感觉自己这个写法很笨，变成数字列表，然后翻转；格式要求：ABABBABA
"""
import datetime


def split_number(number):
    """拆分成数字列表"""
    number_list = []
    while number:
        number_list.append(number%10)
        number = number // 10
    return number_list

def is_palindromes(number):
    """判断是否是回文数"""
    number_list = split_number(number)
    flag= 0
    if number_list == number_list[::-1]:
        flag = 1
        if number_list[0] == number_list[2] == number_list[5] == number_list[7] and number_list[1] == number_list[3] == number_list[4] == number_list[6]:
            flag = 2
    else:
        flag = 0
    return flag


def main():
    input_date = input()
    result1, result2 = [], []
    date = datetime.datetime.strptime(input_date, "%Y%m%d")
    delta = 0
    while True:
        delta += 1
        new_date = date + datetime.timedelta(delta)
        new_date = new_date.strftime("%Y%m%d")
        flag = is_palindromes(int(new_date))
        if flag:
            if flag == 1:
                result1.append(new_date)
            else:
                result1.append(new_date)
                result2.append(new_date)
        if result2 and result2:
            break

    print(result1[0])
    print(result2[0])


if __name__ == "__main__":
    main()